<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Gets an array of all MongoCollections for this database</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongodb.lasterror.html">MongoDB::lastError</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongodb.preverror.html">MongoDB::prevError</a></div>
 <div class="up"><a href="class.mongodb.html">MongoDB</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongodb.listcollections" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB::listCollections</h1>
  <p class="verinfo">(PECL mongo &gt;=0.9.0)</p><p class="refpurpose"><span class="refname">MongoDB::listCollections</span> &mdash; <span class="dc-title">Gets an array of all MongoCollections for this database</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb.listcollections-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><strong>MongoDB::listCollections</strong></span>
    ([ <span class="methodparam"><span class="type">bool</span> <code class="parameter">$includeSystemCollections</code><span class="initializer"> = false</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   Gets a list of all the collections in the database and returns them as an
   array of <a href="class.mongocollection.html" class="classname">MongoCollection</a> objects.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb.listcollections-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<em><code class="parameter">includeSystemCollections</code></em></dt>

    <dd>

     <p class="para">
      Include system collections.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongodb.listcollections-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an array of MongoCollection objects.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb.listcollections-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>1.3.0</td>
      <td>
       Added the <em><code class="parameter">includeSystemCollections</code></em> parameter.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>



 <div class="refsect1 examples" id="refsect1-mongodb.listcollections-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1398">
   <p><strong>Example #1 <span class="function"><strong>MongoDB::listCollections()</strong></span> example</strong></p>
   <div class="example-contents"><p>
    The following example demonstrates dropping each collection in a database.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$m&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">selectDB</span><span style="color: #007700">(</span><span style="color: #DD0000">"sample"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$list&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">listCollections</span><span style="color: #007700">();<br />foreach&nbsp;(</span><span style="color: #0000BB">$list&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$collection</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"removing&nbsp;</span><span style="color: #0000BB">$collection</span><span style="color: #DD0000">...&nbsp;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">drop</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"gone\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
removing sample.blog.posts... gone
removing sample.critical.docs... gone
removing sample.taxes... gone
...
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongodb.listcollections-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="mongodb.getcollectionnames.html" class="function" rel="rdfs-seeAlso">MongoDB::getCollectionNames()</a> - Get all collections from this database</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongodb.lasterror.html">MongoDB::lastError</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongodb.preverror.html">MongoDB::prevError</a></div>
 <div class="up"><a href="class.mongodb.html">MongoDB</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
